#import "RCTPayssion.h"


@implementation Payssion

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(pay:(NSDictionary *)payload)
{
    PayRequest *payRequest = [[PayRequest alloc] init];
    payRequest.live_mode = false;
    payRequest.api_key = @"916937a82dd7af5a";
    payRequest.secret_key = @"demo456";
    payRequest.pm_id = @"momo_vn";
    payRequest.amount = @"200";
    payRequest.currency = @"USD";
    payRequest.order_id = @"order id 12345213";
    payRequest.descriptions = @"IOS order by payssion, orderId:12345213";

    PaymentMainController *paymentMainController = [[PaymentMainController alloc] init];
    paymentMainController.payRequest = payRequest;
    paymentMainController.paymentDelegate = self;
    paymentMainController.hidesBottomBarWhenPushed = YES;
    UIViewController * viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
//    [viewController pushViewController:paymentMainController animated:YES];
    
    dispatch_async(dispatch_get_main_queue(), ^{

        UINavigationController * nv = [[UINavigationController alloc] initWithRootViewController:paymentMainController];
        [viewController presentViewController:nv animated:YES completion:nil];
    });
}

- (void)processOrderWithPayResponse:(PayResponse *)payResponse{
    if (payResponse != nil) {
        NSLog(@"%@",payResponse.mOrderId);
    }
}
@end
